pub mod db;
pub mod hot;
pub mod tasks;
pub mod utils;

use tasks::start_hot_search_collection;
use tokio::signal;
use tracing::{info, level_filters::LevelFilter};
use tracing_appender::rolling::{RollingFileAppender, Rotation};
// use std::fs::File;
// use std::io::{BufRead, BufReader, Error, Read};

#[tokio::main]
async fn main() {
    let file_appender = RollingFileAppender::new(Rotation::DAILY, "log_files", "myapp.log");
    let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender);

    tracing_subscriber::fmt()
        .with_writer(non_blocking)
        // .with_max_level(LevelFilter::INFO)
        .with_max_level(LevelFilter::INFO)
        .init();
    start_hot_search_collection().await;
    // Wait for Ctrl+C signal to gracefully shut down
    tokio::select! {
        _ = signal::ctrl_c() => {
            tracing::info!("Received Ctrl+C, shutting down...");
        },
    }
}
